package demo.test;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;

/**
 * @author : GF
 * @date : 2019/2/19 10:56
 */
public class JsonParseToJO {

    public static void main(String[] args) {
        JSONObject jo = new JSONObject();
        jo.put("name", "feiji");
        jo.put("age", 20);
        System.out.println(jo.toJSONString());
        System.out.println("-----------------------");
        User u = JSON.toJavaObject(jo, User.class);
        System.out.println(u);
        System.out.println(u.getAge());
    }

    @Data
    static class User{
        Integer age;
        String name;
    }
}
